package vn.igolf.geo;

public class Point {
	private double x;
	private double y;

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	public int getIntegerX () {
		return (int) Math.round(this.x);
	}
	
	public int getIntegerY () {
		return (int) Math.round(this.y);
	}
	
	public double distanceToPoint (Point p) {
		double ret = (p.x-x) *(p.x-x) + (p.y-y)*(p.y-y);
		ret = Math.sqrt(ret);
		return ret;
	}
	public double dotProduct (Point A,Point B,Point C){
		double[] AB = new double[2];
		double[] BC = new double[2];
		AB[0] = B.getX()-A.getX();
		AB[1] = B.getY()-A.getY();
		BC[0] = C.getX()-B.getX();
		BC[1] = C.getY()-B.getY();
		double dot = AB[0] * BC[0] + AB[1] * BC[1];
		
		return dot;
	}
	public double distanceToLine (Line d){
		double ret = 0;
		ret = Math.abs(d.getaL()*this.getX()-this.getY()+d.getbL())/Math.sqrt(d.getaL()*d.getaL()+1);
		return ret;
	}
 	
}
